<template>
    <div class="recordDetail">
      <Navbar :appTitle="$route.meta.title" @ClickRight="$router.push('/application')"/>

      <!-- 基本信息 -->
      <div class="otherTaps">
        <div class="title">
          <span class="icon"></span>
          <span class="content">基础信息</span>
        </div>
        <div class="content">
          <div class="row">
            <span class="r-label">工单编号：</span>
            <span class="r-column">{{ detailInfo.orderCode || "-" }} </span>
          </div>
          <div class="row">
            <span class="r-label">生产物品：</span>
            <span class="r-column">{{ detailInfo.serialNumber || "-" }} | {{ detailInfo.serialName || "-" }} | {{ detailInfo.serialSpecifications || "-" }} </span>
          </div>
          <div class="row">
            <span class="r-label">工序：</span>
            <span class="r-column">{{detailInfo.processesName || "-"}}</span>
          </div>
          <div class="row">
            <span class="r-label">操作人：</span>
            <span class="r-column">{{ detailInfo.userText || "-" }}</span>
          </div>
          <div class="row">
            <span class="r-label">合格数：</span>
            <span class="r-column">{{ detailInfo.qualifiedNum || 0 }}</span>
          </div>
          <div class="row">
            <span class="r-label">不合格数：</span>
            <span class="r-column">{{ detailInfo.unqualifiedNum || 0 }}</span>
          </div>
          <div class="row">
            <span class="r-label">不合格原因：</span>
            <span class="r-column">{{ detailInfo.nonconformityDescribe || "-" }}</span>
          </div>
          <div class="row">
            <span class="r-label">报工时间：</span>
            <span class="r-column">{{ detailInfo.reportTime || "-" }}</span>
          </div>

        </div>
      </div>


            <!-- 自定义信息 -->
      <div class="otherTaps">
        <div class="title">
          <span class="icon"></span>
          <span class="content">自定义信息</span>
        </div>

        <div class="content" v-if="detailInfo.extDataJson.length > 0">
          <div class="row" v-for="(item, index)  in detailInfo.extDataJson" :key="index">
            <span class="r-label">{{item.fieldName}}：{{ item.fieldValue || '-' }}</span>
            <!-- <span class="r-column"> {{ item.fieldValue || '-' }} </span> -->
          </div>
          
        </div>
        <van-empty v-else description="自定义信息为空" />

      </div>

    </div>
  </template>
  
  <script>
  import Navbar from "@/components/navBar/navBar_right";
  import { produceOrderReportWorkQueryById } from "@/api/productionApply";
  import { 
  formTypeExtendedFieldList,
} from "@/api/mobile";
  export default {
    name: "goodsManagementDetail", //物品详情
    components: { Navbar },
    data() {
      return {
        detailInfo: {
          extDataJson:[]
        },
        formTypeExtendedFields:[]
      };
    },
    computed: {},
    mounted() {},
    created() {
      this.getDetail();
    },
    methods: {

     async getDetail() {
      // 获取报工自定义表单字段;
      await formTypeExtendedFieldList({formType: 4}).then((res) => {
        if(res.code == 200 && res.result) {
          this.formTypeExtendedFields = res.result
        }
      });

        let id = this.$route.query.item.id;
        produceOrderReportWorkQueryById({id}).then((res) => {
          if (res.code == 200) {
            this.detailInfo = res.result;

            for(const item in this.detailInfo.extDataJson) {
            this.formTypeExtendedFields.map((ele) => {
              if(ele.fieldKey == item) {
                ele.fieldValue = this.detailInfo.extDataJson[item]
              }
            })
          }
          this.detailInfo.extDataJson = this.formTypeExtendedFields
          } else {
            this.$toast(res.message);
          }
        });
      },

    },
  };
  </script>
  <style lang="scss" scoped>

  .recordDetail {
    height: 100vh;
    //   overflow-y: scroll;
    .d-head {
      width: 100%;
      padding: 32px;
      background: #ffffff;
      .content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        .left {
          width: 560px;
          // border: 1px solid red;
          .title {
            font-size: 32px;
            font-family: PingFang SC;
            font-weight: 500;
            color: #191f25;
            line-height: 44px;
  
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            -o-text-overflow: ellipsis;
          }
          .row {
            font-size: 28px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #888888;
            margin-top: 20px;
          }
        }
        .right {
          // border: 1px solid red;
          width: 120px;
          .rightImg {
            display: block;
            width: 110px;
            height: 110px;
            //   margin-left: 0.45rem;
            // border: 1px solid blue;
          }
        }
      }
    }
  
    .otherTaps {
      background: #ffffff;
      padding: 32px;
      margin-top: 20px;
      .title {
        padding-bottom: 20px;
        border-bottom: 1px solid #eeeeee;
        .icon {
          display: inline-block;
          width: 6px;
          height: 28px;
          background: #1890ff;
        }
        .content {
          width: 126px;
          height: 32px;
          font-size: 32px;
          font-family: PingFang SC;
          font-weight: bold;
          color: #191f25;
          line-height: 44px;
          margin-left: 20px;
        }
      }
      .content {
        .row {
          font-size: 28px;
          font-family: PingFang SC;
          font-weight: 400;
          margin-top: 32px;
          display: flex;
          .r-label {
            color: #888888;
            display: block;
            // max-width: 5rem;
            word-break: break-word;
            // width: 0.7rem;
            //   border: 1px solid red;
          }
          .r-column {
            display: block;
            color: #191f25;
            width: 500px;
            //   border: 1px solid red;
            //    width: 1rem;
          }
        }
        .fhrow {
          display: flex;
          .fhImg {
            width: 110px;
            height: 110px;
            border-radius: 20px;
          }
          .rt-column {
            width: 510px;
            //   height: 2.55rem;
            margin-left: 40px;
            .rt-title {
              font-size: 32px;
              font-family: PingFang SC;
              font-weight: 500;
              color: #191f25;
              margin-bottom: 32px;
            }
            .rt-row {
              display: flex;
              justify-content: space-between;
              margin-bottom: 46px;
              .column {
                //    border: 1px solid red;
                width: 300px;
                .column-t {
                  font-size: 28px;
                  font-family: PingFang SC;
                  font-weight: 400;
                  color: #888888;
                  display: block;
                  width: 100%;
                  margin-bottom: 6px;
                }
                .column-c {
                  font-size: 32px;
                  font-family: PingFang SC;
                  font-weight: 400;
                  color: #191f25;
                  display: block;
                  width: 100%;
                }
              }
            }
          }
        }
      }
    }
    .search-bottom {
      height: 100px;
      width: 100%;
      background: #ffffff;
      // background: red;
      display: flex;
      justify-content: space-between;
      align-items: center;
      position: fixed;
      bottom: 0px;
      padding: 22px;
      .btnconfirm {
        width: 344px;
        height: 78px;
        background: #1890ff;
        border-radius: 0px;
        text-align: center;
        line-height: 78px;
        color: #ffffff;
      }
      .btncancel {
        width: 344px;
        height: 78px;
        background: #f6f6f6;
        border: 2px solid rgba(25, 31, 37, 0.12);
        border-radius: 0;
        text-align: center;
        line-height: 78px;
      }
    }
  }
  .contentBox {
    margin-top: 276px;
  }
  
  .otherMargin {
    height: 20px;
    background: #f5f5f5;
  }
  .bottomLine {
    height: 2px;
    background-color: #f0f0f0;
    margin: 32px 32px 0 32px;
  }
  .ExamineBottom {
    height: 100px;
  }
  .status {
    display: inline-block;
    margin-top: 32px;
    padding: 6px 16px;
    background: #edf6ff;
    border-radius: 4px;
    font-size: 22px;
    font-family: PingFang SC;
    font-weight: 400;
    color: #3774ac;
  }
  </style>
  